#include <bits/stdc++.h>
using namespace std;

#define ONLINE_JUDGE		

#ifndef ONLINE_JUDGE
#define dbg(x...) { cerr << "\033[32;1m" << #x << " -> "; err(x); }
void err() { cerr << "\033[39;0m" << endl; }
template<typename T, typename... A>
void err(T a, A... x) { cerr << a << ' '; err(x...); }
#else
#define dbg(...)
#endif

typedef long long LL;


#define next _next

const int N = 1e5+50;

char s[N];

vector<int> G[N];

int deg[N];
void add(int u, int v)
{
	G[u].push_back(v);
	G[v].push_back(u);
}


inline int next(int u, int fa)
{
	for (int v : G[u])
		if (v != fa)
			return v;
	return -1;
}


bool go(int st, vector<int> &ans, bool vis[])
{
	ans.push_back(st); vis[st] = 1;
	dbg(st);

	int fa = st, now = next(st, -1);
	for (; ~now && G[now].size() > 1;)
	{
		if (vis[now])
			return false;
		dbg(now, fa, G[now].size());
		ans.push_back(now);
		vis[now] = 1;

		int t = now;
		now = next(now, fa);
		fa = t;

		dbg("new", now, fa);
	}
	if (~now)
	{
		ans.push_back(now);
		vis[now] = 1;
	}
	return true;
}

int main(int argc, char const *argv[])
{
	int t;
	scanf("%d", &t);
	for (int kk=0; kk<t; ++kk)
	{
		scanf("%s", s);
		for (int i=0; i<30; ++i)
			G[i].clear();

		int n = strlen(s);
		for (int i=0; i<n-1; ++i)
		{
			int u = s[i] - 'a',
			v = s[i+1]-'a';
			add(u, v);
		}
		memset(deg, 0, 4 * 26);
		for (int i=0; i<26; ++i)
		{
			sort(G[i].begin(), G[i].end());
			G[i].resize(unique(G[i].begin(), G[i].end()) - G[i].begin());
			for (int x : G[i])
				++deg[x];
		}

		vector<int> l[30];

		bool suc = true;

		for (int i=0; i<26; ++i)
		{
			if (deg[i] > 3)
			{
				dbg(">3", i);
				suc = false;
				break;
			}
			l[deg[i]].push_back(i);
		}
		if (!suc)
		{
			puts("NO");
			continue;
		}
		int htNum = l[0].size() + l[1].size();

		if (htNum < 2)
		{
			puts("NO");
			continue;
		}

		static bool vis[26];

		vector<int> ans;
		memset(vis, 0, sizeof vis);
		dbg(vis[0], G[0].size());
		for (int x : l[0])
		{
			if (!vis[x])
			{
				go(x, ans, vis);
			}
			dbg(x, vis[0]);
		}


		for (int x : l[1])
		{
			if (!vis[x])
			{
				if (!go(x, ans, vis))
				{
					suc = false;
					break;
				}
			}
		}

		dbg(vis[0]);

		for (int i=0; i<26; ++i)
			if (!vis[i])
			{
				suc = false;
				break;
			} else dbg(i, vis[i]);
		if (!suc)
		{
			puts("NO");
			continue;
		}
		puts("YES");
		for (int x : ans)
			printf("%c", x + 'a');
		putchar('\n');

	}
	return 0;
}